<style>
	.header  { height: 120px; padding: 10px;}
	.header img { width: 90px;  padding: 0;}
	.header .plat_title { text-align: center; font-family: "微软雅黑"; color: orangered; line-height: 90px; 
		text-shadow: 2px 2px 5px grey; font-size: 42px; font-style: italic; font-weight: bolder; vertical-align: bottom;}
	.header .plat_title span { font-size: 14px; font-style: normal; margin-left: 10px; }

	.main { width: 100%; height: 400px; margin-top: 60px; display: flex; flex-flow: column nowrap; justify-content: center; align-items: center; }
	.main input { width: 60%; height: 32px; margin-top: 6px; }
	.main button { width: 90px; height: 32px; margin-top: 6px; }
</style>
<section>
	<div class="header mui-bar mui-bar-nav">
		<img src="../image/kklogo_600W.png">
		<div class="plat_title">快快统计平台<span>移动端</span></div>

	</div>
	
	<div class="mui-content">
		<div class="main">
			<input type="password" name="oldpassword" placeholder="请输入旧密码">
			<input type="password" name="password" placeholder="请输入新密码">
			<input type="password" name="password2" placeholder="请再次输入新密码">
			<div>
				<button class="btn_change">变更</button>
				<button class="btn_return">返回</button>
			</div>
		</div>
	</div>
</section>
<script>
	console.log("this is changepassword")
	$(".btn_change").on("tap", function(){
		var old = $("input[name=oldpassword]").val();
		var pw = $("input[name=password]").val();
		var pw2 = $("input[name=password2]").val();
		if(!old || !pw  || !pw2 ){
			alert("请输入旧密码和将要使用的新密码");
		}else if(pw != pw2){
			alert("两次输入新密码不一致");
		}else{
			var conditions = JSON.stringify({user_id: userlogin.userID});
			$.post("http://101.200.201.27/adm/mkap/aj/pub/curd.php", {do: 'select', table: 'tj.operation_users', conditions: conditions} , function(r){
				// console.log(r)
				if(r[0].password != hex_md5(old)){
					alert('旧密码不正确')
				}else{
					var fields = JSON.stringify({password: hex_md5(pw)});
					var conditions = JSON.stringify({user_id: userlogin.userID});
					$.post("http://101.200.201.27/adm/mkap/aj/pub/curd.php", {do: 'update', table: "tj.operation_users", fields: fields, conditions: conditions}, function(r){
						console.log(r)
						userlogin = null;
						rd.navito("login", "login");
					})
				}
			}, 'json')
		}
	})
	
	$(".btn_return").on("tap", function(){
		rd.navito("pages", "homepage");
	})

	$("input[type=password]").keyup(function(e){
		if(e.keyCode == 13){
			$("button.btn_change").click();
		}
	})
</script>